home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
gsdbloo.exe
/
DEMOB004.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-02-24
|
3KB
|
92 lines
program DemoB004;
{------------------------------------------------------------------------------
DBase File Lister
Sample 4
Demo Program
Copyright (c) Richard F. Griffin
10 February 1992
102 Molded Stone Pl
Warner Robins, GA 31088
-------------------------------------------------------------
This program demonstrates how dBase fields may be modified using
Griffin Solutions units.
If the DEMOB1.DBF file does not exist, the program will display a
a message that the file was not found and to run DEMOB001 to make
the file.
The program initializes a dBase file object, opens the file, and
proceeds to list selected fields from each record.
It will reverse all the letters in LASTNAME and write the record
back to disk.
Finally, it will read the file back in, list the new values, put
the old LASTNAME back to the record by reversing letters again, and
writing the record again.
-------------------------------------------------------------------------------}
uses
CRT,
DOS,
GS_Date,
GS_dBase,
GS_DBFld,
GS_FileH;
var
MyFile : GS_dBFld_Objt;
ftest : file;
i : integer;
s1,
s2 : string[30];
c : char;
procedure WorkTheFile; {reads the file, displays fields, and }
{reverses LASTNAME }
begin
MyFile.GetRec(Top_Record); {Get the first record in the file}
while not MyFile.File_EOF do {Repeat until end-of-file}
begin
s1 := MyFile.StringGet('LASTNAME');
writeln(s1,', ',
MyFile.StringGet('FIRSTNAME'));
s2 := '';
for i := 1 to length(s1) do s2 := s1[i] + s2;
Myfile.StringPut('LASTNAME',s2);
MyFile.PutRec(MyFile.RecNumber);
MyFile.GetRec(Next_Record); {Get the next sequential record}
end;
end;
{------ Main Routine ------}
begin
ClrScr;
if not GS_FileExists(ftest, 'DEMOB1.DBF') then
begin
writeln('File DEMOB1.DBF not found. Run DEMOB001 to create.');
halt;
end;
{The 'Real' example starts here}
MyFile.Init('DEMOB1'); {Initialize object using the dBase III}
{file DEMOB1. DBF Extension assumed}
MyFile.Open; {Open the object's file}
WorkTheFile;
writeln('------ Now to show LASTNAME is reversed in the file:');
write('Press any Key to continue:');
c := ReadKey;
writeln;
WorkTheFile;
MyFile.Close;
writeln('------ OK, the file is back in shape now');
write('Press any Key to continue:');
c := ReadKey;
end.